<template>
  <!-- 分配角色 -->
  <el-dialog
    title="分配角色"
    :visible.sync="showDialog"
    :close-on-click-modal="issShow"
    :show-close="issShow"
    @open="open"
    @closed="closeDialog"
  >
    <el-checkbox-group v-model="checkList">
      <el-checkbox v-for="item in RoleList" :key="item.id" :label="item.id">{{
        item.name
      }}</el-checkbox>
    </el-checkbox-group>
    <div slot="footer" class="dialog-footer">
      <el-button @click="showDialog = false">取 消</el-button>
      <el-button type="primary" @click="confirm">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { assignRoles } from '@/api/employee'
export default {
  name: 'AssignRoles',
  data() {
    return {
      issShow: false,
      showDialog: false,
      // 权限选中列表
      checkList: [],
      // 权限分配所有列表
      RoleList: [],
      employeesId: ''
    }
  },
  computed: {},
  methods: {
    // 关闭弹窗的回调事件
    closeDialog() {
      this.RoleList = []
    },
    // 弹窗打开完毕时回调事件
    async open() {},
    // 弹窗确定的点击事件
    async confirm() {
      await assignRoles({ id: this.employeesId, roleIds: this.checkList })
      this.$message.success('分配角色成功')
      this.showDialog = false
    }
  }
}
</script>

<style></style>
